#include "stdafx.h"

void init_all(){
	stm32_Clock_Init(6);
	usart1_init(72,115200);
	usart2_init(72,74880);
	delay_init(72);
	RTC_Init();
	IWDG_Init(4,1250);
	LED_Init();
	OLED_Init();
	SHT2x_Init();
	AT24CXX_Init();
	ADC_Init();
}

void ready(){
	if((RCC->CFGR&0x10008)==0x10008)OLED_ShowString(2,0,(u8 *)"RCC:HSE->PLL  [72Mhz]",12);
	else if((RCC->CFGR&0x08)==0x08)OLED_ShowString(2,0,(u8 *)"RCC:HSI->PLL  [72Mhz]",12);
	else OLED_ShowString(2,52, (u8 *)"RCC:OTHER",12);
	OLED_ShowString(2,12,AT24CXX_Check()==0?(u8 *)"EEPROM OK":(u8 *)"EEPROM ERROR",12);
	OLED_Refresh_Gram();
	delay_ms(100);
	for(u8 d=0;d<128;d++){
		OLED_DrawPoint(d,60,1);
		OLED_DrawPoint(d,61,1);
		OLED_DrawPoint(d,62,1);
		OLED_DrawPoint(d,63,1);
		OLED_Refresh_Gram();
	}
	OLED_Clear();
	printf("%s","USART1_OK\n");
	usart2_printf("%s","USART2_OK\n");
	//AT24CXX_Write(234,(u8*)"EEPROM READ      0-21",21);
}

int main(){
	init_all();
	ready();
	task_start();
}
